package com.jffccloud.provider.web.rpc;

import com.codingapi.txlcn.commons.annotation.TxTransaction;
import com.jffccloud.common.web.BaseController;
import com.jffccloud.common.web.wrapper.WrapMapper;
import com.jffccloud.common.web.wrapper.Wrapper;
import com.jffccloud.provider.api.model.OrderDto;
import com.jffccloud.provider.api.service.OrderFeignApi;
import com.jffccloud.provider.api.model.Demo;
import com.jffccloud.provider.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RefreshScope
@RestController
@Api(value = "API - OmcOrderQueryFeignClient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OrderFeignClient extends BaseController<DemoService,Demo> implements OrderFeignApi {
    @Override
    @ApiOperation(httpMethod = "POST", value = "根据订单号查询订单信息")
    public Wrapper<OrderDto> queryByOrderNo(@PathVariable("orderNo") String orderNo) {
        logger.info("selectByOrderNo - 根据订单号查询订单信息. orderNo={}", orderNo);
        OrderDto orderDto = new OrderDto();
        orderDto.setId(1l);
        orderDto.setOrderNo("www");
        orderDto.setPayment(new BigDecimal(999));
        orderDto.setStatus(99);
        return WrapMapper.ok(orderDto);
    }

    @Override
    @ApiOperation(httpMethod = "POST", value = "新增demo")
    public Wrapper insertDemo(@RequestBody Demo demo) {
        service.insert(demo);
        return WrapMapper.ok();
    }
}
